import java.util.*;


public class Solution {
    /**
     * 代码中的类名、方法名、参数名已经指定，请勿修改，直接返回方法规定的值即可
     *
     * 
     * @param s string字符串 
     * @param n int整型 
     * @return string字符串
     */
    public String trans (String s, int n) {
        // write code here
        if (n == 0) return null;
        String[] tmp = s.split(" ", -1);
        StringBuilder ret = new StringBuilder();
        for (int i = tmp.length - 1; i >= 0; i--) {
            ret.append(fun(tmp[i]));
            if (i != 0) {
                ret.append(" ");
            }
        }
        return ret.toString();
    }
    private String fun(String s) {
        StringBuilder ret = new StringBuilder();
        for (int i = 0; i < s.length(); i++) {
            char c = s.charAt(i);
            if (c >= 'a' && c <= 'z') {
                c += (char) ('A' - 'a');
            } else if (c >= 'A' && c <= 'Z') {
                c -= (char) ('A' - 'a');
            }
            ret.append(c);
        }
        return ret.toString();
    }

    public static void main(String[] args) {
        Solution solution = new Solution();
        // System.out.println(solution.fun("AbCdEffG"));
        String s = "This is a sample";
        System.out.println(solution.trans(s, 16));
    }
}